import { Injectable, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
import { Observable, of } from 'rxjs';
import { tap, take } from 'rxjs/operators';

@Injectable()
export class LoggerInterceptor implements NestInterceptor {
  intercept(context: ExecutionContext, next$: CallHandler): Observable<any> {
    console.log('Before....')
    const now = Date.now()
    
    return next$.handle().pipe(
      tap(() => console.log(`After... ${Date.now() - now}ms`))
    )
  }
}